# Find installed GLFW

# GLFW requires OpenGL
find_package(OpenGL)

# find include path
find_path(GLFW_INCLUDE_DIR
   NAMES GL/glfw.h
   DOC "GLFW include path"
)

# find static library
find_library(GLFW_LIBRARY
   NAMES glfw
   DOC "GLFW API static library path"
)

set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
set(GLFW_LIBRARIES ${GLFW_LIBRARY} ${OPENGL_LIBRARIES})

if (OPENGL_FOUND AND GLFW_INCLUDE_DIR AND GLFW_LIBRARY)
   set(GLFW_FOUND TRUE)
   if (NOT GLFW_FIND_QUIETLY)
      message (STATUS "Found GLFW: ${GLFW_LIBRARY}")
   endif()
else()
   set(GLFW_FOUND FALSE)
   if (GLFW_FIND_REQUIRED)
      if (NOT OPENGL_FOUND)
         message(FATAL_ERROR "Could not find OpenGL (required by GLFW)")
      else()
         message(FATAL_ERROR "Could not find GLFW")
      endif()
   endif()
endif()
